package com.lyj.controller;

import com.lyj.pojo.OldMan;
import com.lyj.pojo.SatisNurseName;
import com.lyj.pojo.Satisfaction;
import com.lyj.service.OldManService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class OldManController {

    @Autowired
    OldManService oldManService;

//查询全部
    @RequestMapping("/queryAllOldMan")
    @ResponseBody
    public List<OldMan> queryAllOldMan(){
        List<OldMan> oldManList = oldManService.queryAllOldMan();
        return oldManList;
    }
//关键字查询
    @RequestMapping("/queryOldManByName")
    @ResponseBody
    public List<OldMan> queryOldManByName(String oldName){
        List<OldMan> oldManList = oldManService.queryOldManByName(oldName);
        return oldManList;
    }
//新增老人记录
    @RequestMapping("/addOldMan")
    @ResponseBody
    public Boolean addOldMan(OldMan oldMan){
        Boolean aBoolean = oldManService.addOldMan(oldMan);
        return aBoolean;

    }

//删除老人记录
    @RequestMapping("/delOldManById")
    @ResponseBody
    public Boolean delOldManById(int oldId){
        Boolean aBoolean = oldManService.delOldManById(oldId);
        return aBoolean;
    }

//修改老人记录
    @RequestMapping("/updateOldManById")
    @ResponseBody
    public Boolean updateOldManById(OldMan oldMan){
        Boolean aBoolean = oldManService.updateOldManById(oldMan);
        return aBoolean;

    }
//查询老人的备用护工
    @RequestMapping("/queryOldManStatis")
    @ResponseBody
    public SatisNurseName queryOldManStatis(int oldId){

        SatisNurseName satisNurseName = oldManService.queryOldManStatis(oldId);
        System.out.println("======"+satisNurseName);
        return satisNurseName;
    }
//更改备用护工表
    @RequestMapping("/updateBysatisId")
    @ResponseBody
    public Boolean updateBysatisId(Satisfaction satisfaction){
        Boolean aBoolean = oldManService.updateBysatisId(satisfaction);
        return aBoolean;

    }


}
